home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / UTIL / SCREEN / CURSES01 / minix / c / boxes < prev    next >
Text File  |  1991-05-05  |  3KB  |  112 lines

  1. /****************************************************************/
  2. /* Box() routines of the PCcurses package            */
  3. /*                                */
  4. /****************************************************************/
  5. /* This version of curses is based on ncurses, a curses version    */
  6. /* originally written by Pavel Curtis at Cornell University.    */
  7. /* I have made substantial changes to make it run on IBM PC's,    */
  8. /* and therefore consider myself free to make it public domain.    */
  9. /*        Bjorn Larsson (...mcvax!enea!infovax!bl)    */
  10. /****************************************************************/
  11. /* 1.0:    Release:                    870515    */
  12. /****************************************************************/
  13. /* Modified to run under the MINIX operating system by Don Cope */
  14. /* These changes are also released into the public domain.      */
  15. /*                             900906  */
  16. /****************************************************************/
  17.  
  18. #include <curses.h>
  19. #include "curspriv.h"
  20.  
  21. /****************************************************************/
  22. /* wbox(win,ymin,xmin,ymax,xmax,v,h) draws a box in window    */
  23. /* 'win', enclosing the area xmin-xmax and ymin-xmax. If    */
  24. /* xmax and/or ymax is 0, the window max value is used. 'v' and    */
  25. /* 'h' are the vertical and horizontal characters to use. If    */
  26. /* 'v' and 'h' are 0, wbox will use the alternate character set */
  27. /* in a pretty way.                        */
  28. /****************************************************************/
  29.  
  30. int    wbox(win,ymin,xmin,ymax,xmax,v,h)
  31. WINDOW    *win;
  32. int         ymin;
  33. int         xmin;
  34. int         ymax;
  35. int         xmax;
  36. int         v;
  37. int         h;
  38. {
  39.   int     vc,hc,ulc,urc,llc,lrc;    /* corner chars */
  40.   int     i,oldattrs;
  41.  
  42.   oldattrs = win->_attrs;
  43.   if (ymax == 0)
  44.   ymax = win->_maxy;
  45.   if (xmax == 0)
  46.   xmax = win->_maxx;
  47.  
  48.   if (ymin >= win->_maxy || ymax > win->_maxy ||
  49.   xmin >= win->_maxx || xmax > win->_maxx ||
  50.   ymin >= ymax || xmin >= xmax)
  51.   return(ERR);
  52.  
  53.   vc = v;
  54.   hc = h;
  55.   ulc = urc = llc = lrc = vc;        /* default same as vertical */
  56.  
  57.   if (v==0 && h==0)
  58.   {
  59.     ulc = ACS_ULCORNER;
  60.     urc = ACS_URCORNER;
  61.     llc = ACS_LLCORNER;
  62.     lrc = ACS_LRCORNER;
  63.     hc = ACS_HLINE;
  64.     vc = ACS_VLINE;
  65.     win->_attrs |= A_ALTCHARSET;
  66.   }
  67.   
  68.   for (i = xmin+1;i <= xmax-1;i++)
  69.   {
  70.     win->_line[ymin][i] = hc | win->_attrs;
  71.     win->_line[ymax][i] = hc | win->_attrs;
  72.   }
  73.   for (i = ymin+1;i <= ymax-1;i++)
  74.   {
  75.     win->_line[i][xmin] = vc | win->_attrs;
  76.     win->_line[i][xmax] = vc | win->_attrs;
  77.   }
  78.   win->_line[ymin][xmin] = ulc | win->_attrs;
  79.   win->_line[ymin][xmax] = urc | win->_attrs;
  80.   win->_line[ymax][xmin] = llc | win->_attrs;
  81.   win->_line[ymax][xmax] = lrc | win->_attrs;
  82.  
  83.   for (i=ymin; i <= ymax ; i++)
  84.   {
  85.     if (win->_minchng[i] == _NO_CHANGE)
  86.     {
  87.       win->_minchng[i] = xmin;
  88.       win->_maxchng[i] = xmax;
  89.     } /* if */
  90.     else
  91.     {
  92.       win->_minchng[i] = min(win->_minchng[i], xmin);
  93.       win->_maxchng[i] = max(win->_maxchng[i], xmax);
  94.     } /* else */
  95.   } /* for */
  96.   win->_attrs=oldattrs;
  97.   return(OK);
  98. } /* box */
  99.  
  100. /****************************************************************/
  101. /* box(win,v,h) draws a box around window window 'win'. 'v' and    */
  102. /* 'h' are the vertical and horizontal characters to use.    */
  103. /****************************************************************/
  104.  
  105. void    box(win,vc,hc)
  106. WINDOW    *win;
  107. int         vc;
  108. int         hc;
  109. {
  110.   wbox(win,0,0,0,0,vc,hc);
  111. } /* box */
  112.